/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nxlv2.nomad.accessdb.services;

import com.nxlv2.nomad.accessdb.dao.IArticleDao;
import com.nxlv2.nomad.accessdb.dao.IClientDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcArticleDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcClientDao;
import com.nxlv2.nomad.businessobjects.Article;
import com.nxlv2.nomad.businessobjects.Client;
import com.nxlv2.nomad.businessobjects.DetailCommande;
import com.nxlv2.nomad.businessobjects.DetailDemande;
//import com.nxlv2.nomad.businessobjects.DetailCommande;
//import com.nxlv2.nomad.businessobjects.DetailDemande;
import com.nxlv2.nomad.businessobjects.Prix;
import java.util.List;

/**
 *
 * @author Nastasia
 */
public class ArticleServices {
    private static final IArticleDao dao = new JdbcArticleDao();
    private static final IClientDao daoC = new JdbcClientDao();    
    
    /**
     * 
     * @param article
     * @param client
     * @throws ServiceException 
     */
    public void create(Article article, Client client) throws ServiceException {
        dao.saveArticle(article);
        daoC.lierArticleAClient(article, client);
    }
    
    /**
     * 
     * @param article
     * @throws ServiceException 
     */
    public void update(Article article) throws ServiceException {
        dao.updateArticle(article);
    }
    
    /**
     * 
     * @param article
     * @throws ServiceException 
     */
    public void delete(Article article) throws ServiceException {
        dao.deleteArticle(article.getIdAppli());
    }
    
    /**
     * 
     * @param id
     * @return
     * @throws ServiceException 
     */
    public Article get(int id) throws ServiceException {
        return dao.findArticleById(id);
    }
    
    /**
     * 
     * @param article
     * @return
     * @throws ServiceException 
     */
    public List<Prix> getPrix(Article article) throws ServiceException {
        return dao.getPrixParArticle(article);
    }
    /**
     * 
     * @param article
     * @return
     * @throws ServiceException 
     */
    public List<Prix> getPrixMaj(Article article) throws ServiceException {
        return dao.getPrixMajParArticle(article);
    }
    
    public Article existByIdbase(int idbase){
        return dao.existByIdbase(idbase);
    }
    
    /**
     * 
     * @param prix
     * @param article
     * @throws ServiceException 
     */
    public void linkPrix (Prix prix ,Article article) throws ServiceException {
        dao.lierPrixAArticle(prix, article);
    }
    
//    /**
//     * 
//     * @param article
//     * @throws ServiceException 
//     */
//    public void getDetailCommandes(Article article) throws ServiceException {
//        dao.getDetailCommandesParArticle(article);
//    }
//    
//    /**
//     * 
//     * @param detailCommande
//     * @param article
//     * @throws ServiceException 
//     */
//    public void linkDetailCommande (DetailCommande detailCommande ,Article article) throws ServiceException {
//        dao.lierDetailCommandeAArticle(detailCommande, article);
//    }
//    
//    /**
//     * 
//     * @param article
//     * @throws ServiceException 
//     */
//    public void getDetailDemandes(Article article) throws ServiceException {
//        dao.getDetailDemandesParArticle(article);
//    }
//    
//    /**
//     * 
//     * @param detailDemande
//     * @param article
//     * @throws ServiceException 
//     */
//    public void linkDetailDemande (DetailDemande detailDemande ,Article article) throws ServiceException {
//        dao.lierDetailDemandeAArticle(detailDemande, article);
//    }
    
}
